﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace The_Last_Knights.Helper.Xml
{
    public class Factory
    {
        public static object Read(XElement element, string ID, string type, int level)
        {
            ButtonReader normalButtonReader = new ButtonReader();
            ConditionReader conditionReader = new ConditionReader();
            switch(type)
            {
                case "BackgroundScreen":
                    BackgroundScreenReader backgroundScreenReader = new BackgroundScreenReader();
                    return backgroundScreenReader.Read(element, ID, level);
                case "Border":
                    BorderReader borderReader = new BorderReader();
                    return borderReader.Read(element, ID, level);
                case "ContentForm":
                    ContentFormReader contentFormReader = new ContentFormReader();
                    return contentFormReader.Read(element, ID, level);
                case "NormalForm":
                    NormalFormReader normalFormReader = new NormalFormReader();
                    return normalFormReader.Read(element, ID, level);
                case "Groupbox":
                    GroupboxReader groupboxReader = new GroupboxReader();
                    return groupboxReader.Read(element, ID, level);
                case "Vector2":
                    Vector2Reader vector2Reader = new Vector2Reader();
                    return vector2Reader.Read(element, ID, level);   
                case "NormalButton":                    
                    return normalButtonReader.Read(element, ID, level);                    
                case "Single":
                    return element.Value;
                case "Text":
                    return element.Value;
                case "Label":
                    LabelReader labelReader = new LabelReader();
                    return labelReader.Read(element, ID, level);
                case "OptionScreen":
                    OptionScreenReader optionScreenReader = new OptionScreenReader();
                    return optionScreenReader.Read(element, ID, level);
                case "TabControl":        
                    TabControlReader tabControlReader = new TabControlReader();
                    return tabControlReader.Read(element, ID, level);
                case "PushButton":                   
                    return normalButtonReader.Read(element, ID, level);
                case "Checkbox":
                    CheckboxReader checkboxReader = new CheckboxReader();
                    return checkboxReader.Read(element, ID, level);                    
                case "CheckButton":
                    CheckButtonReader checkButtonReader = new CheckButtonReader();
                    return checkButtonReader.Read(element, ID, level);
                case "Event":
                    EventReader eventReader = new EventReader();
                    return eventReader.Read(element, ID, level);   
                case "PreCondition":
                    return conditionReader.Read(element, ID, level);                    
                case "PosCondition":
                    return conditionReader.Read(element, ID, level);
                case "CreditScreen":
                    CreditScreenReader creditScreenReader = new CreditScreenReader();
                    return creditScreenReader.Read(element, ID, level);
                case "DisableButton":
                    return normalButtonReader.Read(element, ID, level);
                case "PictureBox":
                    PictureBoxReader pictureBoxReader = new PictureBoxReader();
                    return pictureBoxReader.Read(element, ID, level);
            }
            return null;
        }
    }
}
